/*
 * @Author: 天羽落星辰
 * @Date: 2020-07-24 15:24:59
 * @LastEditors: 天羽落星辰
 * @LastEditTime: 2020-09-30 14:28:15
 * @Description: file content
 */
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'contract/index' + location.search,
                    add_url: 'contract/add',
                    edit_url: 'contract/edit',
                    // del_url: 'contract/del',
                    multi_url: 'contract/multi',
                    table: 'contract',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        { checkbox: true },
                        { field: 'id', title: __('Id') },
                        // {field: 'description', title: __('Description')},
                        { field: 'money', title: __('Money'), operate: 'BETWEEN', formatter: function (value, row) { return value * 1 } },
                        { field: 'day', title: __('Day') },
                        { field: 'money', title: __('得到BLS') , formatter: function (value, row) { return value * Config.bls_usdt }},
                        // { field: 'total_revenue', title: __('Total_revenue'), formatter: function (value, row) { return value * 1 +'%'} },
                        // { field: 'get_tcc', title: __('Get_tcc'), operate: 'BETWEEN', formatter: function (value, row) { return value * 1 } },
                        { field: 'nums', title: __('Nums') },
                        { field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {1: __('Normal'), 0: __('Hidden')}},
                        { field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime },
                        { field: 'updatetime', title: __('Updatetime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime },
                        { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});